import hashlib
import os
import socket
import sys
import requests


def get_python_path():
    """
    获取python路径
    :return:
    """
    host_name = socket.gethostname()
    if host_name == "legend":
        python_path = "/home/legend/WorkSpace/python/water_applets/"
    if host_name == "ecs-364582":
        python_path = "/root/water_applets/"
    else:
        python_path = ""
    return python_path


sys.path.append(get_python_path())
import django

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "water_applets.settings")
django.setup()
from models.models import GoodType


def add_good_type():
    GoodType.objects.all().delete()
    data = [
        {
            "id": 1,
            "name": "精品商品"
        },
        {
            "id": 2,
            "name": "水卡套餐"
        }
    ]
    GoodType.objects.bulk_create([GoodType(**item) for item in data])


if __name__ == '__main__':
    add_good_type()
